<p style="color:#222; font-size:12px; font-weight:600; margin:10px;">Você está em: <a href="?pagina=home">Painel Administrativo</a> / <a href="?pagina=sub-listar">Listagem de Sub-Categorias</a> 
    / Cadastro de Sub-Categoria</p>
<?php
include_once('facilitador.php');
conexao();
bloqueia();

$funcao = $_GET['funcao'];
if ($funcao == "") {
    $funcao = "Inserir";
}
$tab = "categoria";

$id = $_GET['id'];
$sql_alt = $MQ("SELECT * FROM ".$tab." WHERE id = '$id'");
while ($linha = $MFA($sql_alt)) {
    $id = $linha['id'];
    $id_categoria = $linha['id_cat'];
    $sub = $_POST['sub'];
    
}
?>

<form name="formUpload" id="formUpload" action="?pagina=sub-cadastrar&funcao=<?php echo $funcao; ?>&id=<?php echo $id; ?>" method="post" enctype="multipart/form-data">
    <table class="tab" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td bgcolor="#999"><strong>Categoria:</strong></td>
            <td bgcolor="#999">
                <select name="categoria" id="categoria">
                    <?php
                    $sql_categoria = $MQ("SELECT * FROM categoria ORDER BY id ");
                    while ($result = $MFA($sql_categoria)) {
                        if ($id_categoria == $result['id']) {
                            ?>
                            <option value="<?php echo $result['id']; ?>" selected><?php echo $result['cat']; ?></option>    
                            <?php
                        } else {
                            ?>
                            <option value="<?php echo $result['id']; ?>"><?php echo $result['cat']; ?></option>    
                            <?php
                        }
                    }
                    ?>
                </select></td>
        </tr>
        <tr>
            <td bgcolor="#999"><strong>Sub-Categoria:</strong></td>
            <td align="left" bgcolor="#999">
                <input type="text" class="edi" name="sub" id="sub" size="40" value="<?php echo stripslashes($sub); ?>"/></td>
        </tr>
        <tr>
            <td bgcolor="#999">&nbsp;</td>
            <td bgcolor="#999"><input class="bo" type="submit"  name="inserir" id="inserir" value="<?php echo $funcao; ?>"/></td>
        </tr>
    </table>
</form>
